package springcloud.easybuy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springcloud.easybuy.api.EasybuyProductServiceClient;
import springcloud.easybuy.entity.EasybuyProduct;

import java.util.List;

//@Controller
@RestController
public class ProductController {

    @Autowired
    private EasybuyProductServiceClient easybuyProductServiceClient;

    @RequestMapping("/product/queryAllProduct")
    public List<EasybuyProduct> queryAll(){
        return easybuyProductServiceClient.queryAllProduct();
    }


    @RequestMapping("/product/findProductById/{id}")
    public List<EasybuyProduct> findById(@PathVariable("id") int id){
        return easybuyProductServiceClient.findById(id);
    }


    @RequestMapping("/product/findById/{id}")
    public EasybuyProduct findByMainId(@PathVariable("id") int id){
        return easybuyProductServiceClient.findByMainId(id);
    }
}
